<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>easy-http测试接口</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <meta name="Keywords" content="mzlion,easy-okhttp,okhttp,easy-okhttp接口"/>
    <meta name="Description" content="本服务有Mzlion提供的免费HTTP测试接口，主要提供GET和POST等方式"/>
    <link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="//cdn.bootcss.com/highlight.js/9.10.0/styles/atelier-dune-dark.min.css" rel="stylesheet"/>
    <link th:href="${basePath}+'/css/web.css'" rel="stylesheet"/>
</head>
<body>

<!-- Header-->
<header>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <img class="img-responsive" th:src="${basePath}+'/css/images/paper-plane.png'"/>
                <div class="intro">
                    <h1><span class="fw-name">EASY-OKHTTP</span> GETTING START</h1>
                    <div class="star-line"></div>
                    <div class="text">
                        <p>为<span class="fw-name">easy-okhttp</span>提供在线的HTTP测试接口</p>
                        <ul>
                            <li><span class="fw-name">easy-okhttp</span>地址：
                                <a href="https://git.oschina.net/mzllon/easy-okhttp" target="_blank">https://git.oschina.net/mzllon/easy-okhttp</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>

<!-- Content-->
<article>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <h2>接口地址</h2>
                <ul class="list-group">
                    <li class="list-group-item">接口服务地址：<code>https://project.mzlion.com/easy-okhttp/api</code></li>
                    <li class="list-group-item">那么真正的请求地址：接口服务地址+接口名</li>
                </ul>
            </div>
            <div class="col-md-12">
                <h2>接口约定说明</h2>
                <ul class="list-group">
                    <li class="list-group-item">
                        所有接口返回数据格式均为<code>JSON</code>，且数据格式统一，如下所示：
                        <table class="table table-striped table-condensed">
                            <thead>
                            <tr>
                                <th>参数名</th>
                                <th>数据类型</th>
                                <th>参数说明</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>code</td>
                                <td>int</td>
                                <td>接口处理状态码</td>
                            </tr>
                            <tr>
                                <td>errorMessage</td>
                                <td>String</td>
                                <td>接口处理失败消息</td>
                            </tr>
                            <tr>
                                <td>data</td>
                                <td>Object</td>
                                <td>接口响应数据</td>
                            </tr>
                            <tr>
                                <td>fileData</td>
                                <td>Object</td>
                                <td>上传的文件信息，不含文件上传的接口不会返回该参数</td>
                            </tr>
                            <tr>
                                <td>headers</td>
                                <td>JSON</td>
                                <td>自定义Header返回</td>
                            </tr>
                            </tbody>
                        </table>
                    </li>
                    <li class="list-group-item">上传的图片大小不能超过<code>1MB</code></li>
                    <li class="list-group-item"></li>
                </ul>
            </div>
            <div class="col-md-12">
                <h2>接口列表</h2>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        接口名<code>/ip-info</code>
                    </div>
                    <ul class="list-group">
                        <li class="list-group-item">根据IP地址获取地理位置信息</li>
                        <li class="list-group-item">请求方式：<code>GET</code></li>
                        <li class="list-group-item">
                            请求参数：
                            <table class="table table-striped table-condensed">
                                <thead>
                                <tr>
                                    <th>参数名</th>
                                    <th>数据类型</th>
                                    <th>是否为空</th>
                                    <th>参数说明</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td>ip</td>
                                    <td>String</td>
                                    <td>Y</td>
                                    <td>为空时取当前请求的IP，否则以指定的IP</td>
                                </tr>
                                </tbody>
                            </table>
                        </li>
                    </ul>
                    <div class="panel-body">
                        <div class="header">示例代码</div>
                        <figure class="highlight">
                            <pre>
                                <code class="java">ApiResult&lt;Map&lt;String, Object>> ipInfo = HttpClient
    .get("https://project.mzlion.com/easy-okhttp/api/ip-info")
    .queryString("ip", "112.64.217.29")
    .asBean(new TypeRef&lt;ApiResult&lt;Map&lt;String, Object>>>() {
    });</code>
                            </pre>
                        </figure>
                    </div>
                </div>

                <div class="panel panel-default">
                    <div class="panel-heading">
                        接口名<code>/post/simple</code>
                    </div>
                    <ul class="list-group">
                        <li class="list-group-item">普通的表单提交</li>
                        <li class="list-group-item">请求方式：<code>POST</code></li>
                        <li class="list-group-item">
                            请求参数：<strong>满足普通的表单提交即可</strong>
                        </li>
                        <li class="list-group-item">返回数据：<strong>接口会返回提交的参数和自定义Header</strong></li>
                    </ul>
                    <div class="panel-body">
                        <div class="header">示例代码</div>
                        <figure class="highlight">
                            <pre>
                                <code class="java">ApiResult apiResult = HttpClient
    .post("https://project.mzlion.com/easy-okhttp/api/post/simple")
    .param("blog", "https://www.mzlion.com")
    .param("author", "mzlion")
    .param("location", "上海")
    .param("projectName", "easy-okhttp")
    .param("projectUrl", "https://git.oschina.net/mzllon/easy-okhttp")
    .header("customHeader1", "customValue1")//自定义header
    .asBean(ApiResult.class);</code>
                            </pre>
                        </figure>
                    </div>
                </div>

                <div class="panel panel-default">
                    <div class="panel-heading">
                        接口名<code>/post/form</code>
                    </div>
                    <ul class="list-group">
                        <li class="list-group-item">含文件的表单提交</li>
                        <li class="list-group-item">请求方式：<code>POST</code></li>
                        <li class="list-group-item">请求参数：<strong>满足普通的表单(含文件)提交即可</strong></li>
                        <li class="list-group-item">返回数据：<strong>接口会返回提交的参数和自定义Header</strong></li>
                    </ul>
                    <div class="panel-body">
                        <div class="header">示例代码</div>
                        <figure class="highlight">
                            <pre>
                                <code class="java">ApiResult apiResult = HttpClient
    .post("https://project.mzlion.com/easy-okhttp/api/post/form")
    .param("author", "mzlion")
    .param("projectUrl", "https://git.oschina.net/mzllon/easy-okhttp")
    .param("projectName", "easy-okhttp")
    .param("habit", "电影")
    .param("habit", "编程")
    .param("habit", "睡觉")
    .param("logo", this.getClass().getClassLoader().getResourceAsStream("lavender.jpg"), "lavender.jpg")
    .header("customHeader1", "customValue1")//自定义header
    .asBean(ApiResult.class);</code>
                            </pre>
                        </figure>
                    </div>
                </div>

                <div class="panel panel-default">
                    <div class="panel-heading">
                        接口名<code>/post/body/raw</code>
                    </div>
                    <ul class="list-group">
                        <li class="list-group-item">提交请求体(POST Text Body)</li>
                        <li class="list-group-item">请求方式：<code>POST</code></li>
                        <li class="list-group-item">请求内容：<strong>文本或JSON</strong></li>
                        <li class="list-group-item">返回数据：<strong>接口会返回请求时提交的内容</strong></li>
                    </ul>
                    <div class="panel-body">
                        <div class="header">示例代码</div>
                        <figure class="highlight">
                            <pre>
                                <code class="java">ApiResult apiResult = HttpClient
    .textBody("https://project.mzlion.com/easy-okhttp/api/post/body/raw")
    .json("{\"projectList\":[{\"name\":\"easy-okhttp\",\"url\":\"https://git.oschina.net/mzllon/easy-okhttp\"},{\"name\":\"mzlion-core\",\"url\":\"https://git.oschina.net/mzllon/mzlion-core\"}],\"site\":\"https://www.mzlion.com\",\"name\":\"mzlion\",\"location\":\"上海\"}")
    .asBean(ApiResult.class);</code>
                            </pre>
                        </figure>
                    </div>
                </div>


                <div class="panel panel-default">
                    <div class="panel-heading">
                        接口名<code>/post/body/binary</code>
                    </div>
                    <ul class="list-group">
                        <li class="list-group-item">提交请求体(POST Binary Body)</li>
                        <li class="list-group-item">请求方式：<code>POST</code></li>
                        <li class="list-group-item">请求内容：<strong>文件或二进制数据</strong></li>
                        <li class="list-group-item">返回数据：<strong>接口返回文件内容后的BASE64编码后的结果</strong></li>
                    </ul>
                    <div class="panel-body">
                        <div class="header">示例代码</div>
                        <figure class="highlight">
                            <pre>
                                <code class="java">ByteArrayInputStream bais = new ByteArrayInputStream("{\"projectList\":[{\"name\":\"easy-okhttp\",\"url\":\"https://git.oschina.net/mzllon/easy-okhttp\"},{\"name\":\"mzlion-core\",\"url\":\"https://git.oschina.net/mzllon/mzlion-core\"}],\"site\":\"https://www.mzlion.com\",\"name\":\"mzlion\",\"location\":\"上海\"}"
    .getBytes(Charset.forName("UTF-8")));
    ApiResult&lt;String&gt; apiResult = HttpClient
        .binaryBody("https://project.mzlion.com/easy-okhttp/api/post/body/binary")
        .contentType(ContentType.DEFAULT_BINARY)
        .stream(bais)
        .asBean(new TypeRef&lt;ApiResult&lt;String&gt;&gt;() {
            });</code>
                            </pre>
                        </figure>
                    </div>
                </div>
            </div>
        </div>
    </div>
</article>

<!-- footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <p><span>Copyright &copy; 2017 easy-okhttp</span><span><a href="#">浙ICP备15005978号-1</a></span></p>
            </div>
        </div>
    </div>
</footer>
<div class="fix-bottom hidden-sm hidden-xs">
    <a href="#top" class="back-top">回到开始部分</a>
</div>
<script src="//cdn.bootcss.com/jquery/1.12.2/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="//cdn.bootcss.com/zeroclipboard/2.3.0/ZeroClipboard.min.js"></script>
<script src="//cdn.bootcss.com/highlight.js/9.10.0/highlight.min.js"></script>
<script th:src="${basePath}+'/js/core.js'"></script>
</body>
</html>